package com.jd.learn.core.key;

import com.jd.learn.domain.HotSwapModel;

import java.util.concurrent.*;

/**
 * @author shenkaiwen5
 * @version 1.0
 * @date 2020/12/25
 */
public class PushScheduleStarter {

    public static void startPusher(Long period) {
        if (period == null || period <= 0) {
            period = 500L;
        }
        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
        scheduledExecutorService.scheduleAtFixedRate(()->{
            IKeyCollector<HotSwapModel, HotSwapModel> collectHK = KeyHandlerFactory.getCollector();
            //KeyHandlerFactory.getPusher().send(Context.APP_NAME, collectHK.lockAndGetResult());
        },0, period, TimeUnit.MILLISECONDS);
    }
}
